<!DOCTYPE html>
            
<HTML>
<HEAD>
<meta name="booktitle" content="Developing Applications With Objective Caml" >
 <meta charset="ISO-8859-1"><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<META name="GENERATOR" content="hevea 1.05-7 of 2000-02-24">
<META NAME="Author" CONTENT="Christian.Queinnec@lip6.fr">
<LINK rel=stylesheet type="text/css" href="videoc-ocda.css">
<script language="JavaScript" src="videoc.js"><!--
//--></script>
<TITLE>
 Presentation of part II
</TITLE>
</HEAD>
<BODY class="regularBody">
<A HREF="book-ora059.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
<A HREF="index.html"><IMG SRC ="contents_motif.gif" ALT="Contents"></A>
<A HREF="book-ora063.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
<HR>

<H2> Presentation of part II</H2>We describe the set of elements of the environment included in the language
distribution. There one finds different compilers, numerous libraries,
program analysis tools, lexical and syntactic analysis tools, and an
interface with the C language.<BR>
<BR>
Objective CAML is a compiled language offering two types of code generation:
<OL type=1>
<LI>
 <EM>bytecode</EM> to be executed by a <EM>virtual machine</EM>;

<LI> <EM>native code</EM> to be executed directly by a microprocessor.
</OL>
The Objective CAML toplevel uses bytecode to execute the phrases submitted to it.
It constitutes the primary development aid, offering the possibility of
rapid typing, compilation and testing of function definitions. Moreover,
it offers a trace mechanism visualizing parameter values and return values
of functions.<BR>
<BR>
The other usual development tools are supplied by the distribution as well:
file dependency computation, debugging and profiling. The debugger allows
one to execute programs step-by-step, use breakpoints and inspect values.
The profiling tool gives measurements of the number of calls or the amount
of time spent in a particular function or a particular part of the code.
These two tools are only available for Unix platforms.<BR>
<BR>
The richness of a language derives from its core but also from the
libraries, sets of reusable programs, which come with it. Objective CAML is no
exception to the rule. We have already portrayed to a large extent the
graphical library that comes with the distribution. There are many others
which we will describe. Libraries bring new functionality to the language,
but they are not without drawbacks. In particular, they can present some
difficulty vis-a-vis the type discipline.<BR>
<BR>
However rich a language's set of libraries may be, it will always be
necessary that it be able to communicate with another language. The
Objective CAML distribution includes an interface with the C language allowing
Objective CAML to call C functions or be called by them. The difficulty of
understanding and implementing this interface lies in the fact that the
memory models of Objective CAML and C are different. The essential reason for
this difference is that an Objective CAML program includes a garbage collection
mechanism.<BR>
<BR>
C as well as Objective CAML allow dynamic memory allocation, and thus fine
control over space according to the needs of a program. This only makes
sense if unused space can be reclaimed for other use during the course of
execution. Garbage collection frees the programmer from responsibility for
managing deallocation, a frequent source of execution errors. This feature
constitutes one of the safety elements of the Objective CAML language.<BR>
<BR>
However, this mechanism has an impact on the representation of data. Also,
knowledge of the guiding principles of memory management is indispensable
in order to use communication between the Objective CAML world and the C world
correctly.<BR>
<BR>
<P>Chapter <A HREF="index.html#chap-Compilation">7</A> presents the basic elements of the
Objective CAML system: virtual machine, compilers, and execution library. It
describes the language's different compilation modes and compares their
portability and efficiency.<BR>
<BR>
Chapter <A HREF="index.html#chap-Bibliotheques">8</A> gives a bird's-eye view of the set
of predefined types, functions, and exceptions that come with the system
distribution. It does not do away with the need to read the reference
manual ([<A HREF="book-ora214.html#OCAML-ref"><CITE>LRVD99</CITE></A>]) which describes these libraries very well. On
the contrary it focuses on the new functionalities supplied by some of
them. In particular we may mention output formatting, persistence of
values and interfacing with the operating system.<BR>
<BR>
Chapter <A HREF="index.html#chap-GC">9</A> presents different garbage collection methods
in order to then describe the mechanism used by Objective CAML.<BR>
<BR>
Chapter <A HREF="index.html#chap-Aprog">10</A> presents debugging tools for Objective CAML
programs. Although still somewhat frustrating in some respects, these
tools quite often allow one to understand why a program does not work.<BR>
<BR>
Chapter <A HREF="index.html#chap-AlexS">11</A> describes the language's different
approaches to lexical and syntactic analysis problems: a regular expression
library, the <TT>ocamlex</TT> and <TT>ocamlyacc</TT> tools, but also the
use of streams.<BR>
<BR>
Chapter <A HREF="index.html#chap-IC">12</A> describes the interface with the C language.
It is no longer possible for a language to be completely isolated from
other languages. This interface lets an Objective CAML program call a C
function, while passing it values from the Objective CAML world, and vice-versa.
The main difficulty with this interface stems from the memory model. For
this reason it is recommended that you read the <A HREF="index.html#chap-GC">9</A> chapter
beforehand.<BR>
<BR>
Chapter <A HREF="index.html#chap-PART2-Applications">13</A> covers two applications: an
improved graphics library based on a hierarchical model of graphical
components inspired by the JAVA AWT<A NAME="text16" HREF="book-ora062.html#note16"><SUP><FONT SIZE=2>2</FONT></SUP></A>; and a classic program to find least-cost paths in a graph using
our new graphical interface as well as a cache memory mechanism.
<BR>
<BR>
<BR>
<BR>
<HR>
<A HREF="book-ora059.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
<A HREF="index.html"><IMG SRC ="contents_motif.gif" ALT="Contents"></A>
<A HREF="book-ora063.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
</BODY>
</HTML>
